package net.onecloud.onecloud.adapter;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import net.onecloud.onecloud.R;
import net.onecloud.onecloud.application.App;
import net.onecloud.onecloud.model.ResultPost;
import net.onecloud.onecloud.model.ResultRecord;

import java.util.List;

/**
 * Created by zaizai on 16/7/28.
 */
public class PostAdapter extends BaseQuickAdapter<ResultPost.DataEntity> {
    public PostAdapter() {
        super(R.layout.rv_items_post, null);
    }

    @Override
    protected void convert(BaseViewHolder baseViewHolder, ResultPost.DataEntity dataEntity) {
        baseViewHolder.setText(R.id.m_name, dataEntity.getPname())
                .setText(R.id.m_demand, dataEntity.getDemand())
                .setText(R.id.m_welfare, dataEntity.getWelfare())
                .setText(R.id.m_pay, dataEntity.getPay())
                .setText(R.id.m_quantity, dataEntity.getQuantity())
                .setOnClickListener(R.id.m_sumbit_resume, new OnItemChildClickListener())
                .setVisible(R.id.m_hit, false);
        List<ResultRecord.DataEntity> dataEntities = App.getRecordList();
        if (dataEntities != null) {
            for (ResultRecord.DataEntity entity : dataEntities) {
                if (!entity.getPost_id().equals("") && entity.getPost_id().equals(dataEntity.getId())) {
                    baseViewHolder
                            .setVisible(R.id.m_hit, true);
                }

            }
        }

    }
}
